{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## CORDIC Testbench\n",
    "\n",
    "\n",
    "This notebook is to test the implementation of a CORDIC running on the programmable logic. The CORDIC is used to convert cartesian to polar coordinates. The output is compared with a Python calculation of the coordinate transform. It takes in x and y and gives out r and theta where r is the radius and theta is the angle."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pynq import Overlay\n",
    "from pynq import MMIO\n",
    "import numpy as np\n",
    "import struct\n",
    "import binascii\n",
    "import cmath\n",
    "import random\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "NUM_SAMPLES = 50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "ol=Overlay('./design_1_wrapper.bit') #Change name of bitstream as required"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "cordic_ip=MMIO(0x43C00000,0x10000) #Change base address as required"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "r_error=np.zeros(NUM_SAMPLES)\n",
    "theta_error=np.zeros(NUM_SAMPLES)\n",
    "ind=np.arange(NUM_SAMPLES)\n",
    "r_rmse=np.zeros(NUM_SAMPLES)\n",
    "theta_rmse=np.zeros(NUM_SAMPLES)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(NUM_SAMPLES):\n",
    "    #Generating random inputs\n",
    "    x=random.uniform(-1,1)\n",
    "    y=random.uniform(-1,1)\n",
    "    \n",
    "    #Computing golden output\n",
    "    cn=complex(x,y)\n",
    "    cn=cmath.polar(cn)\n",
    "    \n",
    "    #Converting input to bytes to be sent to FPGA\n",
    "    x=(struct.unpack('<I', struct.pack('<f', x))[0])\n",
    "    y=(struct.unpack('<I', struct.pack('<f', y))[0])\n",
    "    \n",
    "    #Writing values to the FPGA\n",
    "    cordic_ip.write(0x10,x)                             #Change the offset as mentioned in vivado file\n",
    "    cordic_ip.write(0x18,y)                             #Change the offset as mentioned in vivado file\n",
    "    \n",
    "    #Starting and stopping the IP (Don't change this)\n",
    "    cordic_ip.write(0x00,1)\n",
    "    cordic_ip.write(0x00,0)\n",
    "    \n",
    "    #Reading from IP\n",
    "    r=hex(cordic_ip.read(0x20))                         #Change the offset as mentioned in vivado file\n",
    "    r=r[2:]\n",
    "    theta=hex(cordic_ip.read(0x28))                     #Change the offset as mentioned in vivado file\n",
    "    theta=theta[2:]\n",
    "    \n",
    "    #Converting to float\n",
    "    if r!=0:\n",
    "        r=struct.unpack('>f', binascii.unhexlify(r))\n",
    "        r=r[0]\n",
    "    if theta!=0:\n",
    "        theta=struct.unpack('>f', binascii.unhexlify(theta))\n",
    "        theta=theta[0]\n",
    "        \n",
    "    #Comparing with golden output    \n",
    "    r_error[i]=\"{0:.6f}\".format(abs(r-cn[0]))\n",
    "    theta_error[i]=\"{0:.6f}\".format(abs(theta-cn[1]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Verifying Functionality"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Radius RMSE:  0.0003398 Theta RMSE: 1.72162713733e-05\n",
      "PASS\n"
     ]
    }
   ],
   "source": [
    "sum_sq_r=0\n",
    "sum_sq_theta=0\n",
    "for i in range(NUM_SAMPLES):\n",
    "    sum_sq_r =sum_sq_r+(r_error[i]*r_error[i])\n",
    "    r_rmse = np.sqrt(sum_sq_r / (i+1))\n",
    "    sum_sq_theta =sum_sq_theta+(theta_error[i]*theta_error[i])\n",
    "    theta_rmse = np.sqrt(sum_sq_theta / (i+1))\n",
    "print(\"Radius RMSE: \", r_rmse, \"Theta RMSE:\", theta_rmse)    \n",
    "if r_rmse<0.001 and theta_rmse<0.001:\n",
    "    print(\"PASS\")\n",
    "else:\n",
    "    print(\"FAIL\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Displaying Errors"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAsgAAAFgCAYAAACmDI9oAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAIABJREFUeJzt3X+8X1V95/vXu0HQVgsa03b4ERMlHRtGq7cR22unY0ElVEu4MziGjg526FDnwrQd71yBthd7qfFCvQ+pdqCVEZRSnUCx1UxNZWzBaWvlRyz+AmU8BpRQrTQE/Ak08Jk/vivj5uv3/Mz5nvP9fs/r+XicR/Zee+3PXuvkm5XPWWftvVNVSJIkSer5nuVugCRJkjRKTJAlSZKkDhNkSZIkqcMEWZIkSeowQZYkSZI6TJAlSZKkDhNkrQhJ7k7ykrb9q0neudxtkqRJl+Q3kvzBcrdDmi8TZI2kltB+O8k3knwlybuTPHkxYlfVm6vqFxYj1gFJXpzksdbe7tdPLOZ1JGmU9I13j3XG7W8k+VcHGfugkuskr03y6IBx+ciDaZdWBhNkjbKfraonA88Dng+cv8ztmc3fVtWT+74+1l8pPd8zW9lskhxysA2WpIPRHe+AL9HG7fb1nuVuH/CxAePy3/ZXGjSeLmSMTbJqoQ3VaDFB1sirqq8A19NLlAFI8vIktyX5WpJ7kvxG95wkr0nyxSR7k/xa37H/NSvRZn739B3vLsc4Psmudp2/S/LWhfQhyUeSbEvyUeBbwDOnKTsyyY4k9yeZSvJv+9p9XZI/SPI14LULaYskLbFDk/x+kq8nuT3JpgMH2pj3viT3JbkryS+18s3ArwKvarO+n2zlP5/ksy3W7iS/uNBGtbH+3CSfAr6Z5JBpyn6kjdcPtPa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EkdJsiSJElShwmyJEmS1PE/ASjYEoqoRhbxAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xaf310530>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(10, 5))\n",
    "plt.subplot(1,2,1)\n",
    "plt.bar(ind,r_error)\n",
    "plt.title(\"Radius Error\")\n",
    "plt.xlabel(\"Index\")\n",
    "plt.ylabel(\"Error\")\n",
    "#plt.xticks(ind)\n",
    "plt.tight_layout()\n",
    "\n",
    "plt.subplot(1,2,2)\n",
    "plt.bar(ind,theta_error)\n",
    "plt.title(\"Theta Error\")\n",
    "plt.xlabel(\"Index\")\n",
    "plt.ylabel(\"Error\")\n",
    "#plt.xticks(ind)\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
